From today on, I will start learning redis source code. The redis code is relatively small and very suitable for learning. It is a very good learning material, it looks like about 100 files, which are written in C language. I hope I can finally get rid of him. I don't need t
原型方法*/Four major modules 1.ReferenceHeader file Declaration 2. macro definition variable definition 3. Data Structure Declaration 4. Method prototype Declaration It is particularly pointed out that the structure definitions of redisobject, redisclient, and redisserver appearing everywhere in the Code are defined in this file. /* The actual Redis Object */#define REDIS_LRU_BITS 24#define REDIS_LRU_CLO
... "); exit (1);} If (configfile) server. configfile = getabsolutepath (configfile); resetserversaveparams (); // load server configurations, load loadserverconfig (configfile, options) according to the config configuration file; sdsfree (options );} else {redislog (redis_warning, "Warning: No config file specified, using The default config. In order to specify a Config File use % S/path/to/% S. conf ", argv [0], server. sentinel_mode? "Sentinel": "redis
the position pattern ++; patternLen --; if (pattern [0] = string [0]) match = 1;} else if (pattern [0] = ']') {// stop break until another brackets exist.} else if (patternLen = 0) {pat Tern --; patternLen ++; break;} else if (pattern [1] = '-' patternLen> = 3) {int start = pattern [0]; int end = pattern [2]; int c = string [0]; if (start> end) {int t = start; start = end; end = t ;} if (nocase) {start = tolower (start); end = tolower (end); c = tolower (c);} pattern + = 2; pat
Redis source code analysis (1) -- Redis Data Structure-string SDS, redissds
1. SDS Overview
The strings used in Redis are Simple Dynamic strings (SDS.
SDS is packaged Based on the C string to make it more suitable for
, set and other frequently used commands, which can be followed by multiple parameter commands, attribute command group commands, generally config get, such a single command is called a common command, Dump, Exist, and so on. There are not many CommandGroup commands as follows:/* All command groups */static char * commandGroups [] = {"generic", "string", "list", "set", "sorted_set", "hash ", "pubsub", "transactions",
The hash table is also one of the data structures supported by Redis, which uses both redis_encoding_ziplist (compressed list) and redis_encoding_ht (data Dictionary) encoding methods.When a hash table uses a compressed list, it uses the following structure to store the data (see ZIPLIST.C):+---------+------+------+------+------+------+------+------+------+---------+| ziplist | | | | | | | | | Ziplist | | ENTRY | Key1 | Val1 | Key2 | Val2 | ... | ...
) {case Redis_string:case redis_hash_zipmap:case REDIS_LIST_ZIPL Ist:case redis_set_intset:case redis_zset_ziplist:case redis_hash_ziplist://Because a struct like ziplist,zipmap is actually a node. Connected to a super string, so is directly read if (!processstringobject (NULL)) {Shift_error (offset, "ERROR reading entry value"); return 0; } break; Case Redis_list:case Redis_set://And the above 2 types are the traditional structure, to divide the node to read for (i = 0; i If the e-
object */INT latencyresetevent (char * event_to_reset)/* reset the latency of the event, delete the event record in the dictionary */void analyzelatencyforevent (char * event, struct latencystats * ls)/* analyze the delay result of the event at a certain time, the result information is stored in the latencystats structure */SDS createlatencyreport (void)/*. Based on the results of the delayed sample, the analysis report with good readability is creat
heavy IO operations, such as AoF's Fsync, calls are made by asynchronous threads, avoiding the event loops that block the main thread. The above is the Initserver function. /* Instances limited to 4GB of address space, so if there is * No explicit limit in the user provided CONFI Guration we set a limit * at 3 GB using MaxMemory with ' noeviction ' policy '. This avoids * useless crashes of the Redis instance for out of memory. * *
tables, both of which achieve high Memory Operation Efficiency ** Copyright (c) 2009-2010, Salvatore Sanfilippo * All rights reserved. ** Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * ** Redistributions of source code must retain the above copyright notice, * thi
Today, we are analyzing the Code Implementation of the string operation class in the redis source code. With several analysis experiences, I gradually felt that I had to change the analysis method. If every API performs
Redis source code analysis () --- create and release a redisObject object, redisredisobject
Today's learning efficiency is relatively high. After analyzing Rio, I learned the RedisObject file, which is about converting and creating RedisObject. Most of the methods are very similar. List the long API list:
/* ---------
; /* it is now possible to unlock the background system as we know have * a stand alone job structure to process. */pthread_mutex_unlock ( bio_mutex [type]);/* process the job accordingly to its type. * // execute the specific job if (type = redis_bio_close_file) {close (long) Job-> arg1);} else if (type = redis_bio_aof_fsync) {aof_fsync (long) Job-> arg1);} else {redispanic ("wrong job type in bioprocessbackgroundjobs (). ");} zfree (job);/* lock again before reiterating the loop, if there are
Redis source code analysis (30th) --- pubsub publish and subscribe Mode
Today I learned the term "Publish and subscribe mode" in Redis, which was first introduced to JMS (Java Message Service) java Message Service. I subscribe to these types of messages. Only when these type
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.